package cn.virens.server.aio.listener.simple;

import java.nio.ByteBuffer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.virens.common.utils.number.ByteUtil;
import cn.virens.server.aio.channel.AioChannel;
import cn.virens.server.aio.listener.AioDataReadListener;

public class SimpleAioDataReadListener implements AioDataReadListener {
	private final Logger logger = LoggerFactory.getLogger(getClass());

	@Override
	public void onRead(AioChannel aioChannel, ByteBuffer buffer) {
		byte[] bs = new byte[buffer.remaining()];
		int position = buffer.position();

		for (int i = 0; i < bs.length; i++) {
			bs[i] = buffer.get(position + i);
		}

		logger.debug("数据已接收:" + aioChannel + "->" + ByteUtil.toHex(bs));
	}

}
